
import { UPDATE_USER_INFO } from "./types";

export default {
    // 更新userInfo
    [UPDATE_USER_INFO]: function (state, payload) { // payload => {adminname,checkedkeys,role,token,a:1,b:2}
        for (var key in payload) { // 遍历传入的数据 得到键名
            if (Object.keys(state.userInfo).includes(key)) { // 判断键名在 userInfo中是否存在
                state.userInfo[key] = payload[key];  // 存在才赋值
            }
        }
    }
}


/* 
let c = "c";

var obj = {
    "a":1,
    "b":2,
    [c]:3
}

obj[c] = 3; */